<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
    <title>Move</title>
    <style>
        #error {
            padding: 15px;
            margin-bottom: 20px;
            border: 1px solid transparent;
            border-radius: 4px;
            color: #a94442;
            background-color: #f2dede;
            border-color: #ebccd1;
            text-align: center;
        }

        #msg {
            padding: 15px;
            margin-bottom: 20px;
            border: 1px solid transparent;
            border-radius: 4px;
            color: #31708f;
            background-color: #d9edf7;
            border-color: #bce8f1;
            text-align: center;
        }

        #login-box {
            padding: 20px;
            background: #fff;
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border: 1px solid #000;
            text-align: right;
        }
    </style>
</head>

<body text="black" bgcolor="white">
<script Language="JavaScript">

    var ms_sux = false;
    var disable_ext = false;

    function get_version(s) {
        result = "";
        for (i = 0; i != s.length; i++)
            if ((s.charAt(i) >= "0") && (s.charAt(i) <= "9"))result += s.charAt(i);
            else break;
        return result;
    }

    if ((navigator.appName == "Microsoft Internet Explorer") && (get_version(navigator.appVersion) < 4)) {
        disable_ext = true;
        ms_sux = true;
    }

    if ((navigator.appName == "Netscape") && (get_version(navigator.appVersion) < 3)) {
        disable_ext = true;
    }

    function move(s, m) {

        document.statistic.row.value = s;
        document.statistic.col.value = m;
    }



    function pic_array(){
        for(n=0;n!=1;n++){
            this[n]=new Image(80,80);
            this[n].src="/web-resources/red.png";
        }
        return;
    }
    if(!disable_ext)
        var Pic=new pic_array();


</script>

<div id="login-box">
    <a href="login">Log Out</a>
</div>

<script type="text/javascript">

    if (!disable_ext)
        with (document) {

            writeln("<div align=center>");
            writeln('<form name="tables">');
            writeln('<table id="table" border=1 cellpadding=0 cellspacing=0>');
            for (y = 8; y != 0; y--) {
                write("<tr>");
                for (x = 1; x != 9; x++){

                    switch (x){

                        case 1: col="A"; break;
                        case 2: col="B"; break;
                        case 3: col="C"; break;
                        case 4: col="D"; break;
                        case 5: col="E"; break;
                        case 6: col="F"; break;
                        case 7: col="G"; break;
                        case 8: col="H"; break;

                    }

                    if (y % 2 == 0) {
                        if (x % 2 != 0) {
                            write('<td><a href=#v777 onClick=move("' + y + '","'+x+'")>' +
                                    '<img src="/web-resources/black.png" name="' + x + y + '" border=0></a></td>');
                        } else {
                    write('<td><a href=#v777 onClick=move("' + y + '","'+x+'")>' +
                            '<img src="/web-resources/white.png" name="' + x + y + '" border=0></a></td>');
                        }
                    }   else {
                        if (x % 2 == 0) {
                            write('<td><a href=#v777 onClick=move("' + y + '","'+x+'")>' +
                                    '<img src="/web-resources/black.png" name="' + x + y + '" border=0></a></td>');
                        } else {
                            write('<td><a href=#v777 onClick=move("' + y + '","'+x+'")>' +
                                    '<img src="/web-resources/white.png" name="' + x + y + '" border=0></a></td>');
                    }
                  }
                }
                write("</tr>");
            }

            writeln("</table></form>");
            writeln('<form name="statistic" method="post" action="move">');
            writeln('<table>');
            writeln('<tr><td><b>Координаты</b></td>');
            writeln('<td><input type="text" readonly size="3" name="row" value="0"></td>');
            writeln('<td><input type="text" readonly size="3" name="col" value="0"></td>');
            writeln('</tr><tr><td>Side:</td><td><input type="number" name="side"></td></tr>');
            writeln('<tr> <td>Figure:</td><td><input type="text" name="figure"></td></tr>');
            writeln('<tr><td><input name="submit" type="submit"value="move" /></td></tr>');
            writeln('</table></form>');
            writeln('</td></tr></table></div>');

            <c:forEach items="${coordinateList}" var="coordinate">

            document.images["${coordinate}"].src=Pic[0].src;

            </c:forEach>

        } else {
        if (ms_sux) {
            document.write("<center><hr><h1>Error!</h1><p aling=left></p></center>Urgh! <b>Обнаружен Microsoft Internet Explorer!</b>Why do you still use this f#cking piece of shit? This stupid browser don't support some extra features (even JavaScript), needed for this game! This site best viewed with <a href='http://www.netscape.com'>Netscape</a> 3.0 or any later version of this really cool browser! And remember Micros0ft is <b>evil and will be destroyed</b>!</p><center><p><a href='http://www.netscape.com/donwload'>Download Netscape now!</a></p><hr></center>");
        } else
            document.write("<center><h1 align=center>Error!</h1><p aling=left>We're sorry, but your browser don't support some extra features, needed for this page! This site best viewed with Netscape 3.0 or any later version of this really cool browser! And remember Micros0ft - <b>SUX</b>!</p><center><a href='http://www.netscape.com/donwload'>Download Netscape now!</a></center>");

    }

</script>

</body>
</html>
